<template>
	<view class="news">
		<news-item :list="newsList" @itemClick="goDetail"></news-item>
		<!-- <view class="news_item" v-for="item in newsList" :key="item.id">
			<image src="item.img_url"></image>
			<view class="right">
				<view class="title">
					{{item.title}}
				</view>
				<view class="info">
					<text>发表时间：{{item.add_time}}</text>
					<text>浏览：{{item.click}}</text>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	import newsItem from '../../components/news-item/news-item.vue'
	export default {
		data() {
			return {
				newsList:[]
			}
		},
		methods: {
			async getNews() {
				const res = await this.$myRuquest({
					url:'/api/getnewslist'
				})
				this.newsList = res.data.message
			},
			goDetail (id) {
				uni.navigateTo({
					url:'/pages/news-detail/news-detail?id='+id
				})
			}
		},
		components:{"news-item":newsItem},
		onLoad() {
			this.getNews()
		}
	}
</script>

<style lang="scss">
	.news{
		
	}
</style>
